
<template>
  <div>
    <h1>我是父组件 - {{myGoods}}</h1>
    <A></A>
  </div>
</template>

<script>
import { ref, provide } from 'vue'
import A from './components/A.vue'
export default {
  components: {
    A
  },
  setup() {
    const myGoods = ref('金佛')
    provide('goods', myGoods)

    provide('changeGoods', (val) => {
      // 在这里改变数据
      console.log('我是爸爸花钱的方法', val)
      if (val < 1000) {
        alert('败家子,不准卖')
        return
      }
      alert('好孙子,咱赚了')
      myGoods.value = val
    })
    return {
      myGoods
    }
  }
}
</script>

<style>

</style>
